<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" isELIgnored="false" import="java.util.*" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>

<head>
<title>历史运价周走势——恒拓运价魔方</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<%-- <script type="text/javascript" src="${pageContext.request.contextPath}/fare/js/show.js"></script>--%>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/fare/js/jquery-1.6.4.min.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/fare/js/datePicker/WdatePicker.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/FusionCharts/FusionCharts.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/fare/lib/ligerUI/js/ligerui.min.js"></script>
<link
	href="<%=request.getContextPath()%>/fare/lib/ligerUI/skins/Aqua/css/ligerui-all.css"
	rel="stylesheet" type="text/css" />
<link href="<%=request.getContextPath()%>/fare/css/base.css"
	rel="stylesheet" type="text/css" />
<script type="text/javascript"
	src="<%=request.getContextPath()%>/jsFile/common.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/jsFile/multiblepicker.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/jsFile/FDCDialog.js"></script>
<link
	href='<%=request.getContextPath()%>/fare/js/cityquery/cityquery.css'
	rel="stylesheet" type="text/css" />
<script type='text/javascript'
	src='<%=request.getContextPath()%>/fare/js/cityquery/citylist.js'></script>
<script type='text/javascript'
	src='<%=request.getContextPath()%>/fare/js/cityquery/querycity.js'></script>

<link rev="stylesheet" media="all" href="<%=request.getContextPath() %>/fare/css/form_style.css" type="text/css" rel="stylesheet">
</head>

<body>
<jsp:include page="../../inc/treelist3.jsp"></jsp:include>
<jsp:include page="/pages/system/feedback/feedback.jsp" ></jsp:include>
<div class="main main_max minhgt450">
	<div class="sideBar">
	<div class="box">
		<div class="location">当前位置： 历史运价走势 &gt; 历史运价周走势</div>
	</div>
	</div>
	<div class="form_table_tltle">
		说明：
		1）在历史运价周走势查询，可查询各航空公司每周运价走势；
	 </div>
	<form id="historyFreight">
		<table cellSpacing=0 cellPadding=0 width="100%" border=0 class="form_table">
			
			<TR>
				<TD width="150" height="26" class="left" style="text-align: left">航空公司：</TD>
				<TD height="26">
				<select id="carrier" name="vo.carrier" class="td1">
						<c:choose>
							<c:when test="${sourceLists == null}">
							</c:when>
							<c:otherwise>
								<c:forEach var="item" items="${sourceLists}">
									<option value="${item.hbaseKey}"
										<c:if test="${item.hbaseKey==vo.carrier}">selected='selected' </c:if>>${item.name}
									</option>
								</c:forEach>
							</c:otherwise>
						</c:choose>
				</select> <span style="color: #ff0000">*</span></TD>
				<td>
				</td>
				<td></td>

			</TR>
			<TR>
				<TD height="26" class="left" style="text-align: left">航&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;线：</TD>
				<TD>
				     <!--   <span>从</span> 
				             <input type="text" style="width: 100px" name="vo.depCity" id="depCity" value="">
					   <span>到</span>
					         <input type="text" style="width: 100px" name="vo.arrCity" id="arrCity" value="">
					   <span style="color: #ff0000">*</span> -->
					   <jsp:include page="/inc/flightSelect.jsp">
	    <jsp:param value="${fromCity}" name="fromCity"/>
	    <jsp:param value="${fromCityCode}" name="fromCityCode"/>
	    <jsp:param value="${toCity}" name="toCity"/>
	    <jsp:param value="${toCityCode}" name="toCityCode"/>
 </jsp:include>
				</TD>
				<TD width="10%" height="26" class="left" style="text-align: left">航班：</TD>
				<TD width="40%">
				<select id="flightNo"name="vo.flightNo" class="td1" onclick="javascript:flightNoSelected()">
						 <option value="">--选 择--</option>
					     <option value="CZ5988">CZ5988</option>
					     <option value="CZ3101">CZ3101</option>
					     <option value="CZ3000">CZ3000</option>
                </select> 08：30 
				</select> 
				     <!--  <span>08：30</span> -->
				</TD>
				
			</TR>
			<TR>
				<TD class="left" style="text-align: left">航班日期：</TD>
				<TD>
					 <input  type="text" style="width: 70px" name="vo.beginDate" id="beginDate" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" required>
					 <span>至</span> 
					 <input type="text" style="width: 70px" name="vo.endDate" id="endDate" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" required> <span></span>
					<!--  <span style="color: #ff0000">*</span> -->
			    </TD>
				<TD class="left" style="text-align: left">提前购买天数：</TD>
				<TD width="40%">
				     <select id="buyDay" name="vo.buyDay" style="width: 70px" class="td1">
				     	<option value="" selected="selected">--选 择--</option>
				     	<option value="0">0天</option>
						<option value="5">5天</option>
						<option value="10">10天</option>
						<option value="15">15天</option>
						<option value="20">20天</option>
						<option value="30">30天</option>
						<option value="45">45天</option>
				    </select>
				   <!--   <span style="color: #ff0000">*</span> -->
			   </TD>
			</TR>
			<TR>
				<TD height="26" class="left" style="text-align: left">出发时段：</TD>
				<TD>
				    <input id="depInterval1" type="checkbox" name="vo.checkbox" value="M">上午
					<input  id="depInterval2" type="checkbox" name="vo.checkbox" value="B">中午
					<input  id="depInterval3" type="checkbox" name="vo.checkbox" value="A">下午 
					<input  id="depInterval4" type="checkbox" name="vo.checkbox" value="N">晚上
				</TD>
				<TD height="26" class="left" style="text-align: left">自定义：</TD>
				<TD colspan="1">
				    <input name="vo.depTimeHour1" type="text" id="depTimeHour1" maxlength="2" style="width: 20px" 
				        onkeyup="this.value=this.value.replace(/\D/g,'')"
					    onafterpaste="this.value=this.value.replace(/\D/g,'')">&nbsp;：
					   
					<input name="vo.depTimeMin1" type="text" id="depTimeMin1"
					maxlength="2" style="width: 20px" 
					onkeyup="this.value=this.value.replace(/\D/g,'')"
					onafterpaste="this.value=this.value.replace(/\D/g,'')">&nbsp;到&nbsp;
					
					<input name="vo.depTimeHour2" type="text" id="depTimeHour2"
					maxlength="2" style="width: 20px" 
					onkeyup="this.value=this.value.replace(/\D/g,'')"
					onafterpaste="this.value=this.value.replace(/\D/g,'')">&nbsp;：
					
					<input name="vo.depTimeMin2" type="text" id="depTimeMin2"
					maxlength="2" style="width: 20px"
					onkeyup="this.value=this.value.replace(/\D/g,'')"
					onafterpaste="this.value=this.value.replace(/\D/g,'')">
				</TD>
			</TR>
			<TR>
				<TD height="26" class="left" style="text-align: left">数据来源：</TD>
				<TD colspan="1">
				    <input type="radio" name="vo.dataSource" checked="checked"
					value="1" />仅官网 
					<input type="radio" name="vo.dataSource"
					value="2" />全渠道
				</TD>
				<TD height="26" class="left" style="text-align: left">舱位等级：</TD>
				<TD >
						<select name="vo.cabinLevel" style="width: 60px" class="td1">
								<option value="1">1</option>
								<option value="2">2</option>
						</select>
				</TD>

			</TR>
			<TR>
				<TD height="35" style="text-align:center" colspan="4">
				     <input type="button" name="searchButton" value="" class="btn01" onclick="javascript:checkJspForm();" id="searchButton" /> 
					 <input type="reset" name="clearButton" value="" class="btn02" id="clearButton" />
				</TD>
			</TR>
		</TABLE>
	</form>
	<div style="display: none">
		<input id="text" type="text" />
	</div>
	
	<div id="lineChartContainer" style="margin-top: 30px; text-align: center;"></div>

	<script type="text/javascript">
 		function setChart(){	
 			$("#lineChartContainer").show();
 			var xml = document.getElementById('text').value;
 			//alert(xml);
 			var width = '750';
 		 	var dateDiffs = parseInt($("#endDateAfterToday").val())*1 - parseInt($("#beginDateAfterToday").val())*1;
 		 	if(dateDiffs*1>15){
 		 		width = (750*1 + (dateDiffs*1-15)*50)+'';
 		 		$('#area_chart').css('width','980px');
 		 	}
		    var chart = new FusionCharts("<%=request.getContextPath()%>/FusionCharts/MSLine.swf", "ChartId", width, "350", "0", "0"); 	   
		  	chart.setDataXML(xml);
		    chart.render("lineChartContainer");		   
 		}
    </script>
	<script type="text/javascript">
		function selectOne(obj) {
			var objCheckBox = document.getElementsByName("checkbox");
			for ( var i = 0; i < objCheckBox.length; i++) {
				//判断复选框集合中的i元素是否为obj，若为否则便是未被选中 
				if (objCheckBox[i] != obj) {
					objCheckBox[i].checked = false;
				} else {
					//若是，原先为被勾选的变成勾选，反之则变成未勾选 
					//objCheckBox[i].checked = obj.checked; 

					//或者使用下句，亦可达到同样效果 
					objCheckBox[i].checked = true;
				}
			}
		}
		

		
		function currentDate() {
			var now = new Date();
			var year = now.getFullYear();
			var month = now.getMonth() + 1;
			var day = now.getDate();

			var today = year + "-";
			if (month < 10)
				today += "0";
			today += month + "-";
			if (day < 10)
				today += "0";
			today += day;
			return (today);
		}
        
		function checkJspForm(){
			if(!checkiForm()){
				return false;
			}
			changeAction('historyAction!getXML.action');
			FDCDialog.lockWindow(true,'<%=request.getContextPath()%>' );
			setTimeout(function(){loadAndDisplayData('historyAction!getXML.action');},1);
		}

		function changeAction(url){
			$('#historyFreight').attr('action',url);
		}
		function checkiForm(){
			if($('#depCity').val()=='中文/拼音' || $('#arrCity').val()=='中文/拼音'){
				alert("请先选择航线!");
				 return false;
			}
			
			if($("#beginDate").val()=="" || $("#beginDate").val()==""){
				if($("#buyDay").val()==''){
					alert("还有航班日期没有选择,请先选择航班日期 或提前购买天数!");
					return false;
				}	
			}
			
			if($("#beginDate").val()!="" || $("#beginDate").val()!=""){
				if($("#buyDay").val()!=''){
					alert("航班日期与提前购买天数只能选择一项!");
					return false;
				}	
			}
			
			/* if ($("#flightNo").val()==""){
				alert("请选择航班!");
				return false;
			} */
			return true;
		}
		
		function loadAndDisplayData(url){
			var beginDate;
			var endDate;
			var checkbox = '';
			
			
			//航班日期与提前购买日期只能二选一
			if($("#buyDay").val()!=''){
				var currentDate = new Date();
				var dataStr = currentDate.getFullYear()+'-'+(currentDate.getMonth()+1)+'-'+currentDate.getDate();
				beginDate = dataStr;
				currentDate.setDate(currentDate.getDate()+parseInt($("#buyDay").val()));
				endDate = currentDate.getFullYear()+'-'+(currentDate.getMonth()+1)+'-'+currentDate.getDate();
				//alert(endDate);
			}else{
				beginDate = $('#beginDate').val();
				endDate   = $('#endDate').val();
			}
			if($("#depInterval1").attr("checked")=='checked'){
				checkbox = $('#depInterval1').val()+',';
			}
			if($("#depInterval2").attr("checked")=='checked'){
				checkbox = checkbox + $('#depInterval2').val()+",";
			}
			if($("#depInterval3").attr("checked")=='checked'){
				checkbox = checkbox + $('#depInterval3').val()+",";
			}
			if($("#depInterval4").attr("checked")=='checked'){
				checkbox = checkbox + $('#depInterval4').val()+",";
			}
			var reg=/,$/gi;
			checkbox = checkbox.replace(reg,"");
			
			if($('#depCity').val()!=''&&$('#arrCity').val()!=''){
				$.ajax({
			        url : url,
			        data:{
			        	'vo.carrier': $('#carrier').val(),
			        	'vo.depCity':$('#depCity').val(),
			        	'vo.arrCity':$('#arrCity').val(),
			        	'vo.flightNo':$('#flightNo').val(),
			        	'vo.beginDate':beginDate,
			        	'vo.endDate': endDate, 
			        	'vo.buyDay':$('#buyDay').val(),
			        	'vo.checkbox' : checkbox,        
			        	'vo.depTimeHour1':$('#depTimeHour1').val(),
			        	'vo.depTimeHour2':$('#depTimeHour2').val(),
			        	'vo.depTimeMin1':$('#depTimeMin1').val(),
			        	'vo.depTimeMin2':$('#depTimeMin2').val(),
			        	'vo.dataSource':$('input[name="vo.dataSource"]:checked').val(),
			        	'vo.cabinLevel':$("#cabinLevel").val()
			        	},
			        cache : false, 
			        async : false,
			        type : "POST",
			       	complete: function(jqXHR, textStatus){
			       		var xml = jqXHR.responseText;
			             
			       		if(jqXHR.status==200){
			       			//判断有没有查询到数据
			       			if(xml.indexOf('dataset')!= -1){
			       				$("#lineChartContainer").show();
			       				$('#text').val(xml);
					        	setChart();		
			       			}else{
			       				$("#lineChartContainer").hide();
			       				alert("该航班没有相应的数据,请重新选择!");
			       			}
				        	
				        	
			       		}
			       	}
			    });
			}
			FDCDialog.unLockWindow();
		}
				
		$(function() {
			$('#depCity').querycity({
				'data' : citysFlight,
				'tabs' : labelFromcity,
				'hotList' : hotList
			});
			$('#arrCity').querycity({
				'data' : citysFlight,
				'tabs' : labelFromcity,
				'hotList' : hotList
			});
		});
	   function	flightNoSelected(){
		   if($("#flightNo").val()!="none"){
			   $("input[name='vo.depInterval1']").attr('disabled',"disabled");
			   $("input[name='vo.depInterval2']").attr('disabled',"disabled");
			   $("input[name='vo.depInterval3']").attr('disabled',"disabled");
			   $("input[name='vo.depInterval4']").attr('disabled',"disabled");
			   $("#depTimeHour1").attr('readonly',"readonly");
			   $("#depTimeMin1").attr('readonly',"readonly");
			   $("#depTimeHour2").attr('readonly',"readonly");
			   $("#depTimeMin2").attr('readonly',"readonly");
			  
		   }
		   else{
			   $("input[name='vo.depInterval1']").removeAttr('disabled',"disabled");
			   $("input[name='vo.depInterval2']").removeAttr('disabled',"disabled");
			   $("input[name='vo.depInterval3']").removeAttr('disabled',"disabled");
			   $("input[name='vo.depInterval4']").removeAttr('disabled',"disabled");
			   $("#depTimeHour1").removeAttr('readonly',"readonly");
			   $("#depTimeMin1").removeAttr('readonly',"readonly");
			   $("#depTimeHour2").removeAttr('readonly',"readonly");
			   $("#depTimeMin2").removeAttr('readonly',"readonly");
			   $("#depTimeHour1").removeAttr("value");
			   $("#depTimeMin1").removeAttr("value");
			   $("#depTimeHour2").removeAttr("value");
			   $("#depTimeMin2").removeAttr("value");
			  
		   }
	   }
	</script>
</div>
<jsp:include page="../../inc/footer2.jsp"></jsp:include>
</body>
</html>